<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div>
  dafanshu12hsawrv
</div>
</body>
<script>
  setTimeout(()=>{
    let con = prompt('请输入要检测的内容,支持正则')
    let reg = new RegExp(con,'g');//g:全局
    console.log(reg)
    let div = document.querySelector('div')
    div.innerHTML = div.innerHTML.replace(reg,search=>{
      return `<span style='color:red'>${search}</span>`
    })
  },200)

</script>
</html>